package com.ln.第一遍1027.demo004;

import java.lang.reflect.Method;

/**
 * @author Ln
 * @version 终极版
 * @date 2022/10/27 16:34
 */
public class Test004 {
    public static void main(String[] args) throws Exception{
        Class<Pig> pigClass = Pig.class;
        Method he = pigClass.getDeclaredMethod("he", String.class, int.class);
        System.out.println("he = " + he);

        Method ha = pigClass.getDeclaredMethod("ha");
        System.out.println("ha = " + ha);

        Method[] declaredMethods = pigClass.getDeclaredMethods();
        for (Method method :declaredMethods){
            System.out.println("method = " + method);
        }

        Method show = pigClass.getMethod("show");
        System.out.println("show = " + show);

        Method[] methods = pigClass.getMethods();
        for (Method method :methods){
            System.out.println("method = " + method);
        }
    }
}
class Person{
    public void show(){
        System.out.println("人的show方法");
    }
    private void hand(){
        System.out.println("人的hand方法");
    }
}
class Pig extends Person{
    public void ha(){
        System.out.println("猪的ha方法");
    }
    public void he(String name,int age){
        System.out.println("猪的he方法");
    }
}
